﻿using System;
using System.Windows;

namespace SlideShowDFG2
{
    /// <summary>
    /// Interaction logic for StartupWindow.xaml
    /// </summary>
    public partial class StartupWindow : Window
    {
        public StartupWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Settings stored in HKEY_CURRENT_USER\Software\zmb\SlideShowDFG2
            RegistryHelper registry = new RegistryHelper();
            if (!registry.AllKeysAvailable())
            {
                MessageBoxResult result = MessageBox.Show("Not all required settings to run are available in the registry.\r\n" +
                                                        "Settings may be added now to continue using this application or it may be closed",
                                                        "Settings Required", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
                switch (result)
                {
                    case MessageBoxResult.Yes :
                        registry.SetDefaults();
                        break;
                    case MessageBoxResult.No :
                        base.Close();
                        break;
                }
            }
        }

        private void btnNew_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Properties["StartupOptions"] = StartupOptions.NewDataFile;
            Application.Current.Properties["FileSystem"] = FileLocationProtocol.LocalFileSystem;
            MainWindow window = new MainWindow();
            window.Show();
            base.Close();
        }
        
        private void btnNewFtp_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Properties["StartupOptions"] = StartupOptions.NewDataFile;
            Application.Current.Properties["FileSystem"] = FileLocationProtocol.FTP;
            MainWindow window = new MainWindow();
            window.Show();
            base.Close();
        }

        private void btnExisting_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Properties["StartupOptions"] = StartupOptions.ExistingDataFile;
            Application.Current.Properties["FileSystem"] = FileLocationProtocol.LocalFileSystem;
            MainWindow window = new MainWindow();
            window.Show();
            base.Close();
        }
        
        private void btnExistingFtp_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Properties["StartupOptions"] = StartupOptions.ExistingDataFile;
            Application.Current.Properties["FileSystem"] = FileLocationProtocol.FTP;
            MainWindow window = new MainWindow();
            window.Show();
            base.Close();
        }
    }
}
